package com.hqd.jjvm.rtda.heap;

import com.hqd.jjvm.rtda.heap.accesss.CommonAccessFlag;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class BaseMember {
    /**
     * 访问权限
     */
    private Integer accessFlags;
    /**
     * 名称
     */
    private String name;

    /**
     * 注解
     */
    private byte[] annotations;

    public boolean isPrivate() {
        return (getAccessFlags() & CommonAccessFlag.ACC_PRIVATE.getHex()) == 0 ? false : true;
    }

    public boolean isStatic() {
        return (getAccessFlags() & CommonAccessFlag.ACC_STATIC.getHex()) == 0 ? false : true;
    }

    public boolean isProtected() {
        return (getAccessFlags() & CommonAccessFlag.ACC_PROTECTED.getHex()) == 0 ? false : true;
    }

    public boolean isFinal() {
        return (getAccessFlags() & CommonAccessFlag.ACC_FINAL.getHex()) == 0 ? false : true;
    }

    public boolean isPublic() {
        return (accessFlags & CommonAccessFlag.ACC_PUBLIC.getHex()) == 0 ? false : true;
    }
}
